package leetcode._0119;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    public List<Integer> getRow(int rowIndex) {
        List<Integer> resultList = new ArrayList<>();
        resultList.add(1);
        if (rowIndex == 0) {
            return resultList;
        }
        if (rowIndex == 1) {
            resultList.add(1);
            return resultList;
        }
        resultList.add(1);
        for (int i = 1; i < rowIndex; i++) {
            resultList.add(0, 1);
            for (int j = 1; j < resultList.size() - 1; j++) {
                resultList.set(j, resultList.get(j) + resultList.get(j + 1));
            }
        }
        return resultList;
    }
}
